﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class notice_notice2 : System.Web.UI.Page
{
    DataClassesDataContext db1 = new DataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack == true)
        {
            BindData();
            int type = Convert.ToInt32(Session["type"].ToString());
            if (type == 0)
            {
                MultiView1.SetActiveView(View2);


            }
            else
            {
                MultiView1.SetActiveView(View1);
            }

        }
    }
    private void BindData()
    {

        int id = Convert.ToInt32(Request.QueryString["id"].ToString());
        var result = (from p in db1.proc_GetNoticInfoById(id)
                      select p).First();
        string name = result.senderName;
        string Date = result.sendTime.ToString();
        string date = Date.Substring(0, 4) + "年" + Date.Substring(5, 2) + "月" + Date.Substring(8, 2) + "日";
        string theme = result.theme;
        string content = result.content;
        Label10.Text = name;
        Label12.Text = date;
        Label15.Text = theme;
        Label16.Text = content;
        //TextBox4.Text = content;
        Label8.Text = name;
        Label9.Text = date;
        TextBox1.Text = theme;
        FreeTextBox1.Text = content;
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("notice.aspx");
        //Literal1.Text = FreeTextBox1.Text;
        //Literal1.Text = this.FreeTextBox1.HtmlStrippedText;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //string editData = Server.HtmlDecode(myEditor.InnerHtml);
        //this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + editData + "');</script>");
        db1.proc_UpdateNoticInfo(Convert.ToInt32(Request.QueryString["id"].ToString()), TextBox1.Text, FreeTextBox1.Text, "");
        db1.SubmitChanges();
        Response.Redirect("notice.aspx");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"].ToString());
        db1.proc_DeleteNoticById(id);
        db1.SubmitChanges();
        Response.Write("<script>alert('删除成功！')</script>");
        Response.Redirect("notice.aspx");
    }
}